package com.qeado.content.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.qeado.content.dao.ProductManageDao;
import com.qeado.content.model.BdTypeCode;
import com.qeado.content.model.KindTypeCode;
import com.qeado.content.model.Product;
import com.qeado.content.model.RkTypeCode;
import com.qeado.content.model.UnitTypeCode;
import com.qeado.content.service.ProductManageService;

@Service
public class ProductManageServiceImpl implements ProductManageService {
	@Autowired
	private ProductManageDao productManageDao ;

	@Override
	public List<Product> getProductListByCondition(Product p) {
		List<Product> prodList =  this.productManageDao.getProductListByCondition(p);
		return prodList;
	}

	@Override
	public void deleProductListById(Product p) {
		this.productManageDao.deleProductById(p);
		
	}

	@Override
	public void insertNewProduct(Product p) {
    	p.setId(UUID.randomUUID().toString());
		this.productManageDao.insertNewProduct(p);
		
	}

	@Override
	public Product searchProductById(String id) {
		return this.productManageDao.searchProductById(id);
	}

	@Override
	public List<BdTypeCode> getAllBrandTypeCode() {
		
		return this.productManageDao.getAllBrandTypeCode();
	}

	@Override
	public List<KindTypeCode> getAllKindTypeCode() {
		return this.productManageDao.getAllKindTypeCode();
	}

	@Override
	public List<RkTypeCode> getAllRankTypeCode() {
		return this.productManageDao.getAllRankTypeCode();
	}

	@Override
	public List<UnitTypeCode> getAllUnitTypeCode() {
		return this.productManageDao.getAllUnitTypeCode();
	}

	@Override
	public void updateProduct(Product p) {
    	this.productManageDao.updateProduct(p);
	}

	@Override
	public List<Map<String, String>> searchUserInfoFromProd(String userName,
			String email) {
		Map<String, String> map = new HashMap<String, String>();
		map.put("userName", userName);
		map.put("email", email);
		return this.productManageDao.searchUserInfoFromProd(map);
	}
	
}
